package com.tjbank.cssys.web.service.impl;

import com.alibaba.fastjson.JSON;
import com.tjbank.cssys.domain.CkLevel;
import com.tjbank.cssys.domain.CkLog;
import com.tjbank.cssys.repository.CkLevelMapper;
import com.tjbank.cssys.web.service.CkLevelService;
import com.tjbank.cssys.web.service.CkLogService;
import com.tjbank.cssys.web.util.GetUserCodeFromToken;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.servlet.http.HttpServletRequest;
import java.util.Date;
import java.util.List;
import java.util.UUID;

@Service
public class CkLevelServiceImpl implements CkLevelService {
    private  static final Logger log = LoggerFactory.getLogger(CkLevelServiceImpl.class);
    @Autowired
    private CkLevelMapper ckLevelMapper;
    @Autowired
    private CkLogService ckLogService;

    @Override
    public List<CkLevel> findByCategory(byte b) {

        return ckLevelMapper.findByCategory(b);
    }


    @Override
    public List<CkLevel> SelectList() {
        return ckLevelMapper.SelectList();
    }
    /*分頁  參數配置*/
    @Override
    public int delete(long id) {
        return ckLevelMapper.delete(id);
    }


    /*category*/
    @Override
    public List<CkLevel> SelectCategory(int category) {
        return ckLevelMapper.SelectCategory(category);
    }

    @Override
    @Transactional
    public boolean insertOrUpdate(CkLevel level ) {

        log.info("CkLevel 添加或更新  参数："+ JSON.toJSONString(level));
        int i = 0;
        if(null!=level.getId()){
            i = ckLevelMapper.updateByPrimaryKey(level);
        }else{
            i = ckLevelMapper.insert(level);
        }

        log.info("CkLevel 添加或更新  结束："+i+"  ==="+ JSON.toJSONString(level));
        if(i==0){
            return false;
        }else{
            return true;
        }

    }

  /*  @Override
    public boolean insertM(CkLevel ckLevel) {
        return ckLevelMapper.insertM(ckLevel);
    }*/
}
